#include "CLogBatch.h"

CLogBatch::CLogBatch()
	: m_tableName("")
{
}
CLogBatch::~CLogBatch()
{
}

void CLogBatch::SetTableName(const std::string& tableName)
{
	m_tableName = tableName;
}
const std::string& CLogBatch::GetTableName() const
{
	return m_tableName;
}

void CLogBatch::AddRecord(const CLogRecordPtr& record)
{
	m_fields.push_back(record);
}
const std::vector<CLogRecordPtr>& CLogBatch::GetRecords() const
{
	return m_fields;
}

int CLogBatch::enumLogRecord(const std::function<int(CLogRecordPtr)>& callback)
{
	for (const auto& record : m_fields)
	{
		int ret = callback(record);
		if (ret != 0)
		{
			return ret; // Stop enumeration if callback returns non-zero
		}
	}

	return 0;
}
